use LWP::Simple;
open OUT,'>',"TyphoonWalkingWay.kml";
my $url='http://david.samsiu.hk/weather/storminfo/detail.php?name=BOLAVEN#txt';
my $coten=get($url);
my $pla;
my $hash=();
while($coten=~/(.*?)\n|\r/g){
	 $pla=$1 if $1=~/(HKO|JMA|CMA|CWB|KMA|JTWC)\s+\-/;	 
	 $hash{$pla}.="$2,$1,0," if $1=~/(\d+\.?\d+)N\s+(\d+\.?\d+)E/;
	}
	
print OUT <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
	<name>typhoon.kml</name>
EOF

for(1..keys %hash){
	my $color=sprintf("%x%x%x%x%x%x", rand(15),rand(15),rand(15),rand(15),rand(15),rand(15));
	print OUT "<Style id=\"style$_\">\n<LineStyle>\n<color>ff",$color,"</color>\n<width>2</width>\n</LineStyle>\n<PolyStyle>\n<color>7f00ff00</color>\n</PolyStyle>\n</Style>\n\n";	
	}
print OUT "<Folder>";

for(keys %hash){
		 (my $co=$hash{$_})=~s/,$//;
			print OUT "\n<Placemark>\n<name>$_预测</name>\n<description>\n<![CDATA[\n<h1>This is prediction by $_!</h1> \n<p><font color=\"red\">something you want to tell me</font></p>\n]]>\n</description>";
			print OUT '\n<styleUrl>#style',++$i,"</styleUrl>\n<LineString>\n<tessellate>1</tessellate>\n<coordinates>",$co,"\n</coordinates>\n</LineString>\n</Placemark>\n\n";
	}
		  print OUT "</Folder>\n</Document>\n</kml>";

